import React from 'react';
import {Layout, Menu, MenuProps, theme} from "antd";
import {FileWordFilled,UsergroupAddOutlined,LaptopOutlined, NotificationOutlined, UserOutlined,PieChartOutlined,DesktopOutlined} from "@ant-design/icons";
import User from "../../views/admin/User";
const { Sider } = Layout;
// 导入导航组件
import {useNavigate}  from 'react-router-dom'

const items2: MenuProps['items'] = [UserOutlined, LaptopOutlined, NotificationOutlined].map(
    (icon, index) => {
        const key = String(index + 1);

        return {
            key: `sub${key}`,
            icon: React.createElement(icon),
            label: `subnav ${key}`,

            children: new Array(4).fill(null).map((_, j) => {
                const subKey = index * 4 + j + 1;
                return {
                    key: subKey,
                    label: `option${subKey}`,
                };
            }),
        };
    },
);
function getItem(label:any, key:any, icon:any, children?:any) {
    return {
        key,
        icon,
        children,
        label,
    };
}
const items = [
    getItem('系统配置', 'system', <PieChartOutlined />, [
        getItem('用户列表', 'user', <UserOutlined/>),
        getItem('角色列表', 'role', <DesktopOutlined />),
        getItem('权限列表', 'power', <UsergroupAddOutlined />),
        getItem('附件列表', 'attachment', <FileWordFilled  />),
    ]),


];
function Index() {
    const navigate = useNavigate()
    const menuClick = (e:any) => {
        console.log("e",e);
        var pathname = '/admin/'+e.keyPath.reverse().join("/");
        navigate(pathname);
    }
    const {
        token: { colorBgContainer },
    } = theme.useToken();
    return (
        <Sider width={200} style={{ background: colorBgContainer }}>
            <Menu
                mode="inline"
                defaultSelectedKeys={['1']}
                defaultOpenKeys={['sub1']}
                style={{ height: '100%', borderRight: 0 }}
                items={items}
                onClick={menuClick}
            />
        </Sider>
    );
}

export default Index;
